package _06封装;

public class Person {
	// 成员变量:
	
		// prviate 私有的
		private String name;
		private int age;
		private boolean married;// 是否已婚
		
		// Setter方法 setXXX
		public void setName(String name)
		{
			this.name = name;
		}
		
		public void setAge(int age)
		{
			if(age>130 || age<1)
			{
				System.err.println("错误的年龄");
				this.age = 18;
				return;
			}
			this.age = age;
		}
		private void setMarried(boolean married)
		{
			this.married = married;
		}
		
		// Getter 方法 getXXX
		public String getName()
		{
			return this.name;
		}
		
		public int getAge()
		{
			return this.age-2;
		}
		
		// boolean类型的get方法  isXXX
		public boolean isMarried()
		{
			return this.married;
		}

		@Override
		public String toString() {
			return "Person [name=" + name + ", age=" + age + "]";
		}
}
